/*
 * @Date: 2022-05-13 10:37:25
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-05-17 21:07:05
 * @FilePath: \react-lvyou\src\router\index.tsx
 * @Description: 路由表
 */
import { lazy } from "react";
import { Navigate, RouteObject } from "react-router-dom";
const Home = lazy(() => import("@/views/Home"));
const NOTFOUND = lazy(() => import("@/views/404NOTFOUND"));
const Login = lazy(() => import("@/views/Login"));
const Register = lazy(() => import("@/views/Register"));
const Recommend = lazy(() => import("@/views/Home/children/recommend"));
const ProductDetail = lazy(() => import("@/views/Home/children/producDetail"));
const SearchPage = lazy(() => import("@/views/Home/children/searchPage"));
const ShoppingCart = lazy(() => import("@/views/shoppingCart"));
const PlaceOrder = lazy(() => import("@/views/placeOrder"));
const routes: RouteObject[] = [
  {
    path: "/",
    element: <Navigate to="/home" />,
  },
  {
    path: "/home",
    element: <Home />,
    children: [
      //默认路径
      {
        path: "",
        element: <Navigate to="recommend" />,
      },
      {
        path: "recommend",
        element: <Recommend></Recommend>,
      },
      //旅游详情
      {
        path: "productdetail/:touristRouteId",
        element: <ProductDetail></ProductDetail>,
      },
      //搜索详情
      {
        path: "search/:keywords",
        element: <SearchPage></SearchPage>,
      },
      {
        path: "search",
        element: <SearchPage />,
      },
      //购物车
      {
        path: "shoppingcart",
        element: <ShoppingCart></ShoppingCart>,
      },
      //订单页面
      {
        path: "placeorder",
        element: <PlaceOrder></PlaceOrder>,
      },
    ],
  },
  //注册
  {
    path: "/register",
    element: <Register />,
  },
  //登录
  {
    path: "/login",
    element: <Login />,
  },

  //404匹配
  {
    path: "/notfound",
    element: <NOTFOUND />,
  },
  {
    path: "*",
    element: <Navigate replace to="/notfound" />,
  },
];

export default routes;
